home *** CD-ROM | disk | FTP | other *** search
/ Suzy B Software 2 / Suzy B Software CD-ROM 2 (1994).iso / picmanip / pic_r2z / showspec / gfa512.lst < prev    next >
File List  |  1995-05-05  |  3KB  |  97 lines

  1. Goto Main
  2. Procedure Malloc(Amt,Ptr)
  3.   ' Amt is how much memory we are setting aside, ptr is the pointer to the start
  4.   ' of this memory...
  5.   Local Pg
  6.   ' Pg is used to calculate an address divisible for 256 that is appropriate...
  7.   Pg=Int(Amt/256)
  8.   ' Checks to see if what we will reserve will be enough for what we wanted...
  9.   ' If not, we increase it...
  10.   If Amt Mod 256<>0
  11.     Inc Pg
  12.   Endif
  13.   ' We set up how much we will actually reserve with Malloc...
  14.   Malloc_amt=Pg*256
  15.   ' Reserves the memory, away from GFA Basic...
  16.   Reserve Fre(0)-Malloc_amt
  17.   ' Now we pass ptr to the GEMDOS Malloc() call that will reserve memory from
  18.   ' the ST's OS...
  19.   *Ptr=Gemdos(&H48,L:Malloc_amt)
  20. Return
  21. '
  22. Procedure Mfree(Adr)
  23.   ' Adr is just the starting address of the area reserved...
  24.   Local Er1
  25.   ' Er1 is used to determine if an error occurred with the use of Mfree...
  26.   ' We also give back the RAM to the OS and GFA Basic...
  27.   Er1=Gemdos(&H49,L:Adr)
  28.   Reserve Fre(0)+Malloc_amt-255
  29.   If Er1<>0
  30.     Cls
  31.     Print "Mfree() error ->";Er1
  32.   Endif
  33. Return
  34. '
  35. Procedure Loader
  36.   Local X
  37.   ' x is used to test for the existence of the file...
  38.   X=Exist(Name$)
  39.   If X<>-1 Then
  40.     Cls
  41.     Print "The program needs to have ";Name$;" present on the same path!"
  42.     Print " The program's execution has now been terminated..."
  43.     Stop
  44.   Endif
  45.   Bload Name$,Dest
  46. Return
  47. '
  48. Main:
  49. ' Now I wanna allocate the memory for BOTH the compressed pic and the final
  50. ' displayable pic...
  51. Gosub Malloc(104000,*Adr)
  52. ' Now, I'm gonna boot in the SPECTRUM 512 compressed pic, into the top most
  53. ' area of that reserved memory... what fun that will be...hehehehehe
  54. ' OK, so, anyways, we wanna have space for the TRIO code, for decompression
  55. ' and displaying of an .SPC pic...
  56. Show$=Space$(675)
  57. Show%=Varptr(Show$)
  58. Decom$=Space$(235)
  59. Decom%=Varptr(Decom$)
  60. Name$="\show512.o"
  61. Dest=Show%
  62. Gosub Loader
  63. Name$="\decomp.o"
  64. Dest=Decom%
  65. Gosub Loader
  66. '
  67. Main2:
  68. Fileselect "\*.SPC","demo.spc",Name$
  69. If Name$="" Then
  70.   Goto Termn8
  71. Endif
  72. Spc%=Adr+52000
  73. Dest=Spc%
  74. Gosub Loader
  75. ' Now, I run the decompression routine, supplied by TRIO Engineering...
  76. ' First we define the destinations for the bitmap and color data...
  77. Bitm%=Adr
  78. Colm%=Bitm%+32000
  79. Dummy=C:Decom%(L:Spc%,L:Bitm%,L:Colm%)
  80. If Dummy<>0 Then
  81.   Cls
  82.   Print "The SPECTRUM picture could not decompress...  Reboot and try again!"
  83.   Stop
  84. Endif
  85. ' Now we put the SPECTRUM pic onscreen until the user presses a key...
  86. Void C:Show%(1,L:Bitm%,L:Colm%)
  87. Repeat
  88. Until Inkey$<>""
  89. ' We have to get the machine out of SPECTRUM mode...
  90. Void C:Show%(0)
  91. ' We give memory back that was used for the .SPC and decompressed SPECTRUM
  92. ' pics...
  93. Goto Main2
  94. Termn8:
  95. Gosub Mfree(Adr)
  96. End
  97.